export function getWindows(id){
	let baseid=document.getElementById(id)
	const width = window.innerWidth ? window.innerWidth : document.body.clientWidth ? document.body.clientWidth : screen.width
	const height = window.innerHeight ? window.innerHeight : document.body.clientHeight ? document.body.clientHeight : screen.height
	baseid.style.width = width+'px';  
　　baseid.style.height =height+'px';  
}

//用法
//   getWindows("baseId");
//  window.onresize=function(){
// 	getWindows("baseId")
//  }   

/*Javascript之获取元素距离页面的top、left、right、bottom*/
export function getElemDis(el) {
    var tp = document.documentElement.clientTop,
        lt = document.documentElement.clientLeft,
        rect =document.getElementById(el).getBoundingClientRect();
		console.log(rect)
    return {
        top: rect.top - tp,
        right: rect.right - lt,
        bottom: rect.bottom - tp,
        left: rect.left - lt
    }
}

//获取dom宽高
export function getDomsty(el) {
     let height=document.getElementById(el).offsetHeight;
	 let width=document.getElementById(el).offsetWidth;
    return {
        height:height,
        width: width
    }
}
//取窗口可视范围的高度 
export const getClientHeight = function() {    
    var clientHeight=0;    
    if(document.body.clientHeight&&document.documentElement.clientHeight){    
        var clientHeight=(document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;            
    }else{    
        var clientHeight=(document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;        
    }    
    return clientHeight;    
}

export const getClientWidth = function() { //获取视窗宽度
    let width = window.innerWidth ? window.innerWidth : document.body.clientWidth ? document.body.clientWidth : screen.width;
	return width;
}


// 取窗口滚动条高度 
export const getScrollTop = function() {    
    var scrollTop=0;    
    if(document.documentElement&&document.documentElement.scrollTop){    
        scrollTop=document.documentElement.scrollTop;    
    }else if(document.body){    
        scrollTop=document.body.scrollTop;    
    }    
    return scrollTop;    
}
// 取文档内容实际高度 
export const getScrollHeight = function() {    
    return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);    
}  

/* 获得元素的位置信息 */
export const getElementPosition = function(elem) {
    var defaultRect = {top: 0, left: 0};
    var rect = (elem.getBoundingClientRect && elem.getBoundingClientRect()) || defaultRect;
    var ret = {
        top: rect.top + document.body.scrollTop,
        left: rect.left + document.body.scrollLeft
    }
    return ret;
}